<?php

namespace app\index\model;

use app\common\controller\ossStorage;
use think\Db;
use think\Model;
use \OSS\OssClient;
/*
 * insertCoproduct 插入公司信息
 * */
class Coproduct extends Model {
    /**
     * @param $companyProduct
     * @return void
     * @throws \Exception
     * ljj
     * 插入公司产品
     */
    public function insertCoproduct($companyProduct)
    {
        $this->saveAll($companyProduct);
    }

    /**获取公司信息
     * @copyright hyw
     * @param $phone
     * @return Coproduct[]|\think\Collection
     */
    public function getProductAttr($companyId) {
        return $this
            ->alias('p')
            ->where('company_id','=',$companyId)
            ->field(['product_img','coproduct','product_introduction','productType'])
            ->where('p.is_delete','=',0)
            ->order('coproduct_id','desc')
            ->limit(2)
            ->select();
    }

    /**
     * @param $companyId
     * @return Coproduct[]|\think\Collection
     * ljj
     * 获取公司产品
     */
    public function getAllProductAttr($companyId){
        return $this->where([['company_id','=',$companyId],['is_delete','=','0']])->select();
    }
}